<?php

namespace app\index\controller;

use think\exception\ValidateException;
use app\model\Agent;
use app\model\MemberCashlogs;

class PaybillController extends Base
{
    public function pay() {

        $money = input('post.money');

        $cashlogsdata['uid'] = UID();
        $cashlogsdata['weid'] = weid();
        $cashlogsdata['order_id'] = '0';
        $cashlogsdata['order_num_alias'] = '0';
        $cashlogsdata['remarks'] = '优惠买单';
        $cashlogsdata['prefix'] = 2;
        $cashlogsdata['amount'] = $money;
        $cashlogsdata['create_time'] = time();

        MemberCashlogs::create($cashlogsdata);
        Agent::where('uid', UID())->dec('income', $money)->update();

        return $this->json(['data' => $data]);
    }
}
